﻿using DevExpress.Utils.Win;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Popup;
using DevExpress.XtraGrid.Demos.util;
using DevExpress.XtraGrid.Editors;
using DevExpress.XtraLayout;
using DiaoPaiDaYin;
using mendian;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using DXApplicationTangche.UC.门店下单.下单;
using DXApplicationTangche.model;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.门店下单.DTO;
using DXApplicationTangche.UC.款式异常;
using DXApplicationTangche.UC.款式管理;
using DXApplicationTangche.service;
using DXApplicationTangche.UC.辅料;
using static DXApplicationTangche.DTO.DTOStyleMeasureItems;
using DXApplicationTangche.UC.款式管理.service;

namespace DXApplicationTangche.UC.Luna
{
    public partial class FrmM2店铺下单选款式新 : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private XtraUserControlC设计点 xtraUserControlC设计点 { get; set; }
        private Enum订单类型 @enum;
        private List<面料选择> 面料选择s = new List<面料选择>();
        public DTOStyleMeasureItems dTOStyleMeasureItems { get; set; }
        private String categoryId;
        private List<DTO款式备选> DTO款式备选s = new List<DTO款式备选>();
        public List<StyleCategoryDTO> styleCategoryDTOs = new List<StyleCategoryDTO>();
        //private DataTable STYLE_CATEGORY;
        public StyleAccessoryItemsDTO styleAccessoryItemsDTO;//辅料保存用dto
        public List<ContrastForUCDto> contrastForUCDtos = new List<ContrastForUCDto>();
        private String 版型名称 { get; set; }
        private String 款式类别 { get; set; }
        private String 制作工艺 { get; set; }
        private String 款式 { get; set; }
        private String 款号 { get; set; }
        private FrmM2店铺统一下单 frm;
        //public DTO坚山款式 dto坚山款式 { get; set; }
        public 门店下单选款式Model model = new 门店下单选款式Model();
        public FrmM2店铺下单选款式新(FrmM2店铺统一下单 frm)
        {
            InitializeComponent();
            this.frm = frm;
            //this.STYLE_CATEGORY = StyleService.GetAllSTYLE_CATEGORY();
            this.styleCategoryDTOs = FunctionHelper.JsonDeserialization<List<StyleCategoryDTO>>(RestCall.httpGetMethod(URL.接口url + "/style/getStyleCategoryAll"));
            this.searchLookUpEdit款式类别.Properties.DataSource = this.styleCategoryDTOs;
            this.searchLookUpEdit款式.Properties.DataSource = this.DTO款式备选s;
            this.面料选择s = FunctionHelper.JsonDeserialization<List<面料选择>>(RestCall.httpGetMethod(URL.接口url + "/material/getMaterialOrderIndexAll"));
            this.searchLookUpEdit面料.Properties.DataSource = this.面料选择s;
        }


        #region 选择面料
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit面料.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                Frm面料选择.mianliao = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "materialNameCn").ToString();
                Frm面料选择.mianliaocd = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "materialCode").ToString();
                this.model.Dto定制下单.materialCode = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "materialCode").ToString();
                this.model.Dto定制下单.materialNameCn = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "materialNameCn").ToString();
                String MLpicurl = RestCall.httpGetMethod(URL.接口url + "/image/getImagePath?materialCode=" + Frm面料选择.mianliaocd);
                if (String.IsNullOrWhiteSpace(MLpicurl) || MLpicurl.Contains("no"))
                {
                    this.pictureBox面料图片.Image = DXApplicationTangche.Properties.Resources.SSHIRT;
                }
                else
                {
                    this.pictureBox面料图片.LoadAsync(URL.图片url + URL.面料图片路径 + MLpicurl);
                }
                this.textBox成分.Clear();
                this.textBox成分.Text = this.searchLookUpEdit面料.Properties.View.GetRowCellValue(rowHandle, "materialComposition").ToString();
            }
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit面料.ToolTip = null;
            searchLookUpEdit面料.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit面料_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = Frm面料选择.mianliaocd + ":" + Frm面料选择.mianliao;
        }
        #endregion

        #region 选择款式类别
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn款式类别_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别View_Click(object sender, EventArgs e)
        {
            var a = this.searchLookUpEdit款式类别.Properties.View.GetSelectedRows();
            foreach (int rowHandle in a)
            {
                this.categoryId = this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "id").ToString();
                this.款式类别 = this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "name").ToString();
                if (this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "code").ToString().Contains("STYLE_CATEGORY-"))
                {
                    this.model.Dto定制下单.STYLE_CATEGORY_CD = this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "code").ToString();
                }
                else
                {
                    this.model.Dto定制下单.STYLE_CATEGORY_CD = "STYLE_CATEGORY-" + this.searchLookUpEdit款式类别.Properties.View.GetRowCellValue(rowHandle, "code").ToString();
                }
                this.DTO款式备选s = FunctionHelper.JsonDeserialization<List<DTO款式备选>>(RestCall.httpGetMethod(URL.接口url + "/style/getStyleMapByCategory?categoryId=" + this.categoryId));
                this.searchLookUpEdit款式.Properties.DataSource = this.DTO款式备选s;
                this.gridView4.RefreshData();
                this.布辅料控件();
            }
        }

        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn款式类别_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit款式类别.ToolTip = null;
            searchLookUpEdit款式类别.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式类别_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.款式类别;
        }
        #endregion

        #region 选择款式
        /// <summary>
        /// 绑定清空事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup popup = form.Controls.OfType<SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl layout = popup.Controls.OfType<LayoutControl>().FirstOrDefault();
            //如果窗体内空间没有确认按钮，则自定义确认simplebutton，取消simplebutton，选中结果label
            if (layout.Controls.OfType<Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮，重写点击事件
                Control clearBtn = layout.Controls.OfType<Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn款式_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
        /// <summary>
        /// 点击选择后的行为
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式View_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            this.款式 = FunctionHelper.GetgridViewValue(this.searchLookUpEdit款式.Properties.View, e.RowHandle, "name").ToString();
            this.款号 = FunctionHelper.GetgridViewValue(this.searchLookUpEdit款式.Properties.View, e.RowHandle, "code").ToString();
            this.textBox款号.Text = this.款号;
            this.textBox款名.Text = this.款式;

            this.model.Dto定制下单.Style_Id = FunctionHelper.GetgridViewValue(this.searchLookUpEdit款式.Properties.View, e.RowHandle, "styleId").ToString();
            //  设计点
            this.model.Dto定制下单.Dto设计点s.Clear();
            this.xtraUserControlC设计点 = new XtraUserControlC设计点(this.款号);
            this.model.Dto定制下单.Dto设计点s = this.xtraUserControlC设计点.Dto设计点s;
            this.initNavigationPage(this.xtraUserControlC设计点);
            //  选中款式
            StyleInfoDto styleInfoDto = 款式Service.getStyleInfoByStyleId(Convert.ToInt32(this.model.Dto定制下单.Style_Id));
            this.model.Dto定制下单.build选中款式(
                                    styleInfoDto.sysStyleId.ToString(), 
                                    styleInfoDto.styleCategoryCd, 
                                    styleInfoDto.styleFitCd, 
                                    styleInfoDto.styleSizeGroupCd,
                                    styleInfoDto.sytleFabricId,
                                    styleInfoDto.styleMakeType
                                    );
            //DataRow dr = SQLmtm.GetDataRow("SELECT * FROM s_style_p WHERE SYS_STYLE_ID='" + this.model.Dto定制下单.Style_Id + "'");
            //this.model.Dto定制下单.build选中款式(
            //                        dr["SYS_STYLE_ID"].ToString(), 
            //                        dr["STYLE_CATEGORY_CD"].ToString(), 
            //                        dr["STYLE_FIT_CD"].ToString(), 
            //                        dr["STYLE_SIZE_GROUP_CD"].ToString(), 
            //                        "", 
            //                        dr["STYLE_MAKE_TYPE"].ToString()
            //                        );//添加选中款式数据
            this.布辅料控件();
            this.chicun01.Items.Clear();
            List<String> 尺码 = new List<string>();
            尺码 = FunctionHelper.JsonDeserialization<List<String>>(RestCall.httpGetMethod(URL.接口url + "/size/findSizeCdByStyleNameCn?styleNameCn=" + this.款号));
            foreach (String str in 尺码)
            {
                this.chicun01.Items.Add(str);
            }
        }
        /// <summary>
        /// 清除按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void clearBtn款式_Click(object sender, EventArgs e)
        {
            this.searchLookUpEdit款式.ToolTip = null;
            searchLookUpEdit款式.EditValue = null;
        }
        /// <summary>
        /// 选完之后的显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchLookUpEdit款式_CustomDisplayText(object sender, DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs e)
        {
            if (null != e.Value)
                e.DisplayText = this.款式;
        }
        #endregion

        private void barEditItemNumber_EditValueChanged(object sender, EventArgs e)
        {
            //this.model.Dto定制下单.build数量(this.barEditItem数量.EditValue.ToString());
        }
        private void gridViewSize_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            this.model.buildCountSize(e.RowHandle, e.Column.FieldName, e.Value.ToString());    //  尺寸计算

            MeasureItemDTO dTOMeasureItem = new MeasureItemDTO(this.model.尺寸呈现[e.RowHandle]);
            RestCall.PostHttp(URL.接口url + "/style/saveMeasureItem?sessionId=" + this.dTOStyleMeasureItems.sessionId, FunctionHelper.JsonSerialization(dTOMeasureItem));
            this.gridControlSize.DataSource = this.model.尺寸呈现;
            String str = FunctionHelper.JsonSerialization(this.model.尺寸呈现);
            this.gridControlSize.Refresh();
        }
        private void gridViewSize_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            //e.Appearance.BackColor = Color.NavajoWhite;
            try
            {
                if (e.Column.Name == "colGarment")
                {
                    if (this.model.尺寸呈现[e.RowHandle].OUT_VALUE > this.model.尺寸呈现[e.RowHandle].leastReasonable)
                    {
                        //该行数据的该列的值不为空时时,其背景色为Red
                        e.Appearance.BackColor = Color.Red;//设置单元格变色
                                                           //e.Column.AppearanceCell.BackColor = Color.Red;//设置数据列变色
                    }
                    else if (this.model.尺寸呈现[e.RowHandle].IN_VALUE > this.model.尺寸呈现[e.RowHandle].maxReasonable)
                    {
                        //该行数据的该列的值不为空时时,其背景色为Red
                        e.Appearance.BackColor = Color.Green;//设置单元格变色
                                                             //e.Column.AppearanceCell.BackColor = Color.Red;//设置数据列变色
                    }
                    else
                    {
                        //e.Appearance.BackColor = Color.LightGray;
                    }
                }
            }
            catch { }
        }
        private void chicun01_SelectedIndexChanged(object sender, EventArgs e)
        {
            //this.model.build选中尺寸(this.chicun01.Text.Trim(), this.model.Dto定制下单.Style_Id, Frm定制下单修改尺寸.stylesizedt);
            this.model.Dto定制下单.STYLE_SIZE_CD = "IGS_GROUP_SIZE-" + this.chicun01.Text.Trim();
            String json = RestCall.httpGetMethod(URL.接口url + "/style/generateStyleMeasureItemsByStyleNameCn?SIZE_CD=" + this.model.Dto定制下单.STYLE_SIZE_CD + "&styleNameCn=" + this.款号 + "&categoryId=" + this.categoryId);
            this.dTOStyleMeasureItems = FunctionHelper.JsonDeserialization<DTOStyleMeasureItems>(json);
            this.treeList尺寸.DataSource = this.dTOStyleMeasureItems.measureItemDTOS;
            this.treeList尺寸.Refresh();
        }
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("确认保存吗？", "保存", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dialogResult == DialogResult.Yes)
            {
                this.model.Dto定制下单.STYLE_NAME_CN = this.textBox款号.Text + " " + this.textBox款名.Text;
                this.model.Dto定制下单.Delete空设计点();
                this.model.Dto定制下单.build数量(this.numericUpDown数量.Value.ToString());
                this.model.build尺寸保存(this.dTOStyleMeasureItems);//尺寸保存
                try
                {
                    //  校验订单
                    this.model.verify订单();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                //辅料保存
                this.styleAccessoryItemsDTO = new StyleAccessoryItemsDTO(this.model.Dto定制下单.STYLE_NAME_CN, this.contrastForUCDtos);
                this.model.Dto定制下单.sessionId = this.model.sessionId;
                this.frm.buildOrderModel(this.model.Dto定制下单, this.styleAccessoryItemsDTO, DXApplicationTangche.model.Enum订单类型.Luna店铺);
                this.frm.refreshGridControl();

                MessageBox.Show("保存成功");
                this.Close();
            }
        }


        private void numericUpDown数量_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (((NumericUpDown)sender).Text.Trim().IndexOf('.') > -1)
            {
                if (((NumericUpDown)sender).Text.Trim().Substring(((NumericUpDown)sender).Text.Trim().IndexOf('.') + 1).Length >= 0)//定义小数位
                {
                    if (!char.IsDigit(e.KeyChar))
                    {
                        e.Handled = false;
                    }
                    else
                    {
                        e.Handled = true;
                    }
                }
            }
        }

        /// <summary>
        /// 初始化导航
        /// </summary>
        /// <param name="uC"></param>
        private void initNavigationPage(XtraUserControl uC)
        {
            uC.Dock = DockStyle.Fill;
            this.dockPanel设计点.Controls.Clear();
            this.dockPanel设计点.Controls.Add(uC);
        }

        private void numericUpDown1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (((NumericUpDown)sender).Text.Trim().IndexOf('.') > -1)
            {
                if (((NumericUpDown)sender).Text.Trim().Substring(((NumericUpDown)sender).Text.Trim().IndexOf('.') + 1).Length >= 0)//定义小数位
                {
                    if (!char.IsDigit(e.KeyChar))
                    {
                        e.Handled = false;
                    }
                    else
                    {
                        e.Handled = true;
                    }
                }
            }
        }


        private void 布辅料控件()
        {
            try
            {
                List<AccessoryItemDTO> accessoryItemDTOs = new List<AccessoryItemDTO>();
                String jsonAccessoryItemDTO = RestCall.httpGetMethod(URL.接口url + "/acc/generateQCItem?styleCategory=" + this.model.Dto定制下单.STYLE_CATEGORY_CD);
                accessoryItemDTOs = FunctionHelper.JsonDeserialization<List<AccessoryItemDTO>>(jsonAccessoryItemDTO);
                this.contrastForUCDtos.Clear();
                foreach (AccessoryItemDTO dto in accessoryItemDTOs)
                {
                    this.contrastForUCDtos.Add(new ContrastForUCDto(dto, new List<DtoForChooseContrasts>()));
                }
                UC辅料 uC辅料 = new UC辅料(this.contrastForUCDtos, this.model.Dto定制下单.STYLE_CATEGORY_CD);
                uC辅料.Dock = DockStyle.Fill;
                this.panel辅料.Controls.Clear();
                this.panel辅料.Controls.Add(uC辅料);
                String str = FunctionHelper.JsonSerialization(contrastForUCDtos);
            }
            catch { }
        }

        private void barButtonItem套号Excel导入_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

        private void treeList尺寸_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)
        {
            //if (e.Column == treeListColumn试样衣尺寸)
            //{
            //    if (this.dTOStyleMeasureItems.hasGarmentSize(this.treeList尺寸.FocusedNode["id"].ToString()))
            //    {
            //        e.Appearance.BackColor = Color.Red;
            //        e.Appearance.Options.UseBackColor = true;
            //    }
            //    else
            //    {

            //    }
            //}
        }

        private void treeList尺寸_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
        {
            try
            {
                this.dTOStyleMeasureItems.build算(this.treeList尺寸.FocusedNode["id"].ToString(), e.Column.FieldName, e.Value.ToString());
                this.dTOStyleMeasureItems.measureItemDTOS.Sort(new DTOMeasureItemIndexComparer());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            this.treeList尺寸.DataSource = this.dTOStyleMeasureItems.measureItemDTOS;
            this.treeList尺寸.Refresh();
        }

        private void treeList尺寸_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
        {
            if (this.treeList尺寸.FocusedColumn == this.treeListColumn加 || this.treeList尺寸.FocusedColumn == this.treeListColumn减)
            {
                if (!FunctionHelper.IsFloat(e.Value.ToString()) || !FunctionHelper.Is半角(e.Value.ToString()))
                {
                    e.ErrorText = "输入格式不正确！";
                    e.Valid = false;
                    return;
                }
            }
        }

        private void pictureBox备注图片1_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "gif,jpg,png|*.gif;*.jpg;*.png;*.jpeg";
            ofd.Title = "请选择图片文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
                {
                    if ("1".Equals(rp.ID))
                    {
                        this.model.Dto定制下单.备注图片s.Remove(rp);
                        break;
                    }
                }
                this.model.Dto定制下单.备注图片s.Add(new 备注图片("1", Image.FromFile(ofd.FileName), "", ofd.FileName));
                this.pictureBox备注图片1.Image = Image.FromFile(ofd.FileName);
            }
        }

        private void pictureBox备注图片2_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "gif,jpg,png|*.gif;*.jpg;*.png;*.jpeg";
            ofd.Title = "请选择图片文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
                {
                    if ("2".Equals(rp.ID))
                    {
                        this.model.Dto定制下单.备注图片s.Remove(rp);
                        break;
                    }
                }
                this.model.Dto定制下单.备注图片s.Add(new 备注图片("2", Image.FromFile(ofd.FileName), "", ofd.FileName));
                this.pictureBox备注图片2.Image = Image.FromFile(ofd.FileName);
            }
        }

        private void pictureBox备注图片3_DoubleClick(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "gif,jpg,png|*.gif;*.jpg;*.png;*.jpeg";
            ofd.Title = "请选择图片文件";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
                {
                    if ("3".Equals(rp.ID))
                    {
                        this.model.Dto定制下单.备注图片s.Remove(rp);
                        break;
                    }
                }
                this.model.Dto定制下单.备注图片s.Add(new 备注图片("3", Image.FromFile(ofd.FileName), "", ofd.FileName));
                this.pictureBox备注图片3.Image = Image.FromFile(ofd.FileName);
            }
        }

        private void richTextBox套号备注_TextChanged(object sender, EventArgs e)
        {
            this.model.build备注(this.richTextBox套号备注.Text);
        }

        private void 删除备注图片1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
            {
                if (1.Equals(rp.ID))
                {
                    this.model.Dto定制下单.备注图片s.Remove(rp);
                    this.pictureBox备注图片1.Image = null;
                    break;
                }
            }
        }

        private void 删除备注图片2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
            {
                if (2.Equals(rp.ID))
                {
                    this.model.Dto定制下单.备注图片s.Remove(rp);
                    this.pictureBox备注图片2.Image = null;
                    break;
                }
            }
        }

        private void 删除备注图片3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (备注图片 rp in this.model.Dto定制下单.备注图片s)
            {
                if (3.Equals(rp.ID))
                {
                    this.model.Dto定制下单.备注图片s.Remove(rp);
                    this.pictureBox备注图片3.Image = null;
                    break;
                }
            }
        }
    }
}
